Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Programming > Pitfall with GetItemValue in LotusScript
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

When 38.3 - 38 equals 0.299999999999997... and what to do about it

Obviously I forgot about the "fraction()" function, so I removedchanged parts of this article (thanks @Mario for the hint) :)   If you need the digits behind the decimal seperator of a number, you might subtract the integer of the number from the number itself: 1.3 int(1.3) e.g. would result ...

When rounding 0.5 equals 0... and what to do about it

Do you know the difference between rounding a number commercially and rounding it mathematically? Notes does... This is, why in Formula @Round(0.5; 1) equals 1, but the equivalent in LotusScript round(0.5, 0) equals 0... Wonder if round(1.5, 0) equals 1? No, the result is...: 2 The reason is, that ...

The third SaveOptions value, or How to suppress the "Do you want to save this document?" message box in Notes

Yes, SaveOptions understands more than just "0" or "1": Did you ever face the problem, that Lotus Notes keeps asking if you want to save the current document, even though you just did? Picture the following scenario: A user creates a document with a certain form that contains a "Change Field ...

Pitfall on NotesUiDocument vs. NotesDocument field changes - unexpected "Reload"

When performing mixed changes on fields, i.e. changing fields in a NotesUiDocument and others in the corresponding backend NotesDocument, it is very important to make sure that they do not have any sideeffects on each other. Could be ugly...   To see what I mean, try this one:   Build a simple ...

Forgotten Notes Features: $PaperColor

Anyone remember, and actually uses (besides in his memos, maybe not knowing) the field "PaperColor" in Lotus Notes documents? Using this field, you can set a dynamic background color in your documents. The field needs to be numeric and contain a number from 1 to 238; usually this field will be ...
Community articlePitfall with GetItemValue in LotusScript
Added by ~Frank Quetlupulikle | Edited by ~Frank Quetlupulikle on March 17, 2010 | Version 2
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: GetItemValue LotusScript

I still often see code like 'NotesDocument.form(0)' in LotusScript agents to access the value of a NotesItem. When the item name and the purpose of the item is not as clear as on "form", I prefer using 'NotesDocument.GetItemValue("form")(0)'. This seems to be the safe way to go, as you will always receive a valid return value; no need to check, if the item is available - the only thing you have to consider is the type of the item, i.e. will you receive e.g. a String or a Double.

 

At least it seems to be that simple - now try composing a document from a form that contains a number field, and add a string to that number field. If you then try to access the value of the field using 'GetItemValue', you will receive - EMPTY. So if you prefer defensive coding (and you should), your code *does* have to look like the following in this case:

 

Dim res as Variant
res = doc.GetItemValue(itemname)
If isEmpty(res) Then
' oops - wrong data type in item
Elseif cstr(res(0)) = "" Then
' item contains an empty string
Else
' valid - do something with it
End if
 

About the Author
Marcus Foerster works as Systems Architect for Pentos AG in Munich, Germany. His focus lies on the application side, creating collaboration systems for users, groups and enterprises to get their daily work done. This approach includes integrating complex workflows with intuitive user interfaces, using Lotus Notes/Domino with Adobe Flex and other Web technologies.
Read more in Marcus' blog: http://marcus.foerster.com/blogexternal link


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (2)
collapsed Versions (2)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (2)Mar 17, 2010, 1:27:00 PM~Frank Quetlupulikle  
1Mar 17, 2010, 1:26:36 PM~Hank Nonhipilygon  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility